const Router = require('koa-router');
const query = require('../mysql');      //这个是封装的查询数据库的方法
const combineRoutes =require('koa-combine-routers')
const homeRouter=require('./homeRouter')
const shiciRouter=require('./shiciRouter')
const xiaoshuoRouter=require('./xiaoshuoRouter')
const loginRouter=require('./loginRouter')


let router = new Router();

//这里我只写这一个测试路由
router.get('/api/test',async(ctx) => {
    let resParams = ctx.query;
    let sql = 'select * from list';
    let list = await query(sql);
    let json = {
        success:true,
        data:list,
		query:resParams
    };
    ctx.response.body = json;
})
router.get('/api/test2',async (ctx)=>{
	const result=['a','v','e','c']
	ctx.response.body=result
})
module.exports = combineRoutes(homeRouter,shiciRouter,xiaoshuoRouter,loginRouter,router);
